using System;

namespace Fornax020.SerialComm.Protocol
{
    /// <summary>
    /// 数据接收事件参数
    /// </summary>
    public class DataReceivedEventArgs : EventArgs
    {
        public byte[] RawData { get; set; }
        public string DataString { get; set; }
        public DateTime Timestamp { get; set; }

        public DataReceivedEventArgs(string dataString)
        {
            DataString = dataString;
            Timestamp = DateTime.Now;
            RawData = System.Text.Encoding.UTF8.GetBytes(dataString);
        }
    }

    /// <summary>
    /// 连接状态变化事件参数
    /// </summary>
    public class ConnectionStatusEventArgs : EventArgs
    {
        public bool IsConnected { get; set; }
        public string Message { get; set; }

        public ConnectionStatusEventArgs(bool isConnected, string message = "")
        {
            IsConnected = isConnected;
            Message = message;
        }
    }

    /// <summary>
    /// 错误事件参数
    /// </summary>
    public class ErrorEventArgs : EventArgs
    {
        public string ErrorMessage { get; set; }

        public ErrorEventArgs(string errorMessage)
        {
            ErrorMessage = errorMessage;
        }
    }
}
